package com.yejq.bingbing.controller;

import java.util.Date;

import com.yejq.bingbing.model.Lover;
import com.yejq.web.annotation.Controller;
import com.yejq.web.annotation.RequestMapping;
import com.yejq.web.model.RequestMethod;
import com.yejq.web.model.ReturnModel;
import com.yejq.web.model.SessionAttribute;

/**
 * 首页
 * 
 * @author yejq
 */
@Controller
public class IndexController {

	public ReturnModel loginPost(String username, int age, Double weight, Date birthday, Lover lover) {
		System.out.println("login method...");
		System.out.println("username:" + username + ", age=" + age + ", weight:" + weight
				+ ", birthday=" + birthday);
		System.out.println("Lover:" + lover);
		ReturnModel returnModel = new ReturnModel();
		// returnModel.setAttribute(new Attribute("lover", lover));
		// returnModel.setUrl("index.jsp");
		returnModel.setSessionAttribute(new SessionAttribute("lover", lover));
		returnModel.setUrl("redirect:index.jsp");
		return returnModel;
	}

	@RequestMapping(value = "/logout", method = RequestMethod.GET)
	public ReturnModel logout() {
		System.out.println("logout method...");
		return null;
	}

	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public ReturnModel login(String username, int age, Double weight, Date birthday, Lover lover) {
		System.out.println("login method...");
		System.out.println("username:" + username + ", age=" + age + ", weight:" + weight
				+ ", birthday=" + birthday);
		System.out.println("Lover:" + lover);
		ReturnModel returnModel = new ReturnModel();
		// returnModel.setAttribute(new Attribute("lover", lover));
		// returnModel.setUrl("index.jsp");
		returnModel.setSessionAttribute(new SessionAttribute("lover", lover));
		returnModel.setUrl("redirect:index.jsp");
		return returnModel;
	}

}
